import { FormSchema } from '/@/components/Form/index';
import { rules } from '/@/utils/helper/validator';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n('system.user');
import { userFields } from '../user/user.data';

export interface ListItem {
  key: string;
  title: string;
  description: string;
  extra?: string;
  avatar?: string;
  color?: string;
}

// tab的list
export const settingList = [
  {
    key: '1',
    name: t('personalInformation'),
    component: 'BaseSetting',
    icon: 'ant-design:user-outlined',
  },
  // {
  //   key: '3',
  //   name: '账号安全',
  //   component: 'AccountSetting',
  //   icon: 'ant-design:lock-outlined',
  // },
  // {
  //   key: '2',
  //   name: '我的租户',
  //   component: 'TenantSetting',
  //   icon: 'ant-design:team-outlined',
  // },

  // {
  //   key: '4',
  //   name: '第三方APP',
  //   component: 'WeChatDingSetting',
  //   icon: 'ant-design:contacts-outlined',
  // },
];

/**
 * 用户表单
 */
export const formSchema: FormSchema[] = [
  {
    field: 'realname',
    component: 'Input',
    label: userFields.realname,
    colProps: { span: 24 },
    required: true,
  },
  {
    field: 'birthday',
    component: 'DatePicker',
    label: userFields.birthday,
    colProps: { span: 24 },
    componentProps: {
      showTime: false,
      valueFormat: 'YYYY-MM-DD',
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'sex',
    component: 'RadioGroup',
    label: userFields.sex,
    colProps: { span: 24 },
    componentProps: {
      options: [
        {
          label: t('man'),
          value: 1,
        },
        {
          label: t('girl'),
          value: 2,
        },
      ],
    },
  },
  // {
  //   field: 'relTenantIds',
  //   component: 'JDictSelectTag',
  //   label: '租户',
  //   colProps: { span: 24 },
  //   componentProps:{
  //     mode:'multiple',
  //     dictCode:'sys_tenant,name,id',
  //     disabled:true
  //   }
  // },
  {
    field: 'post',
    component: 'JDictSelectTag',
    label: userFields.post,
    colProps: { span: 24 },
    componentProps: {
      mode: 'multiple',
      dictCode: 'sys_position,name,code',
      disabled: true,
    },
  },
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

//密码弹窗
export const formPasswordSchema: FormSchema[] = [
  {
    label: userFields.username,
    field: 'username',
    component: 'Input',
    componentProps: { readOnly: true },
  },
  {
    label: userFields.oldpassword,
    field: 'oldpassword',
    component: 'InputPassword',
    required: true,
  },
  {
    label: userFields.newPassword,
    field: 'password',
    component: 'StrengthMeter',
    componentProps: {},
    rules: [
      {
        required: true,
      },
    ],
  },
  {
    label: userFields.confirmNewPassword,
    field: 'confirmpassword',
    component: 'InputPassword',
    dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  },
];
